
#include "client.hpp"


void Menu(char* argv[])
{
    std::cout << "\r" << argv[0] << "    [ip]  " << " [port] " << std::endl;
}

int main(int argc , char* argv[])
{
    if(argc < 3)
    {
        Menu(argv);
        exit(1);
    }
    std::string ip = argv[1];
    uint16_t port = std::stoi(argv[2]);

    Client client(ip , port);
    client.Init();

    pid_t id = fork();
    if(id == 0)
    {
        while(1)
        {
            std::string reply = client.Recv();
            std::cout << reply << std::endl;
        }
    }

    while(1)
    {
        std::string message;
        std::cin >> message;
        client.Send(message);
    }
    return 0;
}